package cn.wolfcode.trip.base.domain;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;

@Getter
@Setter
/*
* 结伴旅游
*
* */
public class CityPlay extends BaseDomain{

    public static final int STATE_RELEASE = 1;//发布
    public static final int STATE_DISABLE = 0;//禁用

    //标题
    private String title;
    //出发地
    private String startplace;
    //去哪玩/目的地
    private String destination;
    //哪个人发布的结伴信息
    private User user;
    //出发时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT-8")
    private Date departureTime;
    //创建时间
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT-8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date creadTime;
    //具体内容
    private String content;
    //背景
    private String coverUrl;
    //状态
    private Integer state=STATE_RELEASE;

    public String getStateName() {
        String temp = "发布";
        if (STATE_DISABLE == state) {
            temp = "禁用";
        }
        return temp;
    }

    public String getJson() {
        HashMap<String, Object> map = new HashMap<>(10);
        map.put("id", id);
        map.put("title", title);
        map.put("destination", destination);
        map.put("departureTime", departureTime);
        map.put("creadTime", creadTime);
        map.put("content", content);
        map.put("coverUrl", coverUrl);
        map.put("state", state);

        if (user!=null){
            map.put("userId", user.getId());
            map.put("userNickName", user.getNickName());
            map.put("userHeadImgUrl()", user.getHeadImgUrl());
            map.put("userPhoneNumber()", user.getPhoneNumber());
        }
        return JSON.toJSONString(map);
    }
}